#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
#define REP(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define PER(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

const int maxn = 2e5 + 500;
int book[maxn], n;
vector<int> a, b;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t = read();
        book[t] = 1;
    }
    for (int i = 1; i <= 2 * n; i++) {
        if (book[i] == 1)
            b.push_back(i);
        else
            a.push_back(i);
    }
    int p = 0, win = 0;
    for (int e: a) {
        int q = upper_bound(b.begin(), b.end(), e) - b.begin();
        if (q > p) {
            ++win;
            p++;
        }
    }
    cout << win << endl;
    return 0;
}